//
//  ShowArrayCollectionViewCell.m
//  GiftSay
//
//  Created by dllo on 16/1/12.
//  Copyright © 2016年 liyinkai. All rights reserved.
//

#import "ShowArrayCollectionViewCell.h"

@interface ShowArrayCollectionViewCell ()

@end

@implementation ShowArrayCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.nameLabel.textColor = [UIColor blackColor];
        self.nameLabel.font = [UIFont systemFontOfSize:14 * SCREEN_WIDTH];
        self.nameLabel.textAlignment = NSTextAlignmentCenter;
        self.nameLabel.layer.borderColor = [UIColor grayColor].CGColor;
        self.nameLabel.layer.borderWidth = 1;
        self.nameLabel.layer.cornerRadius = 5;
        [self addSubview:self.nameLabel];
        
        
    }
    return self;
}

-(void)setName:(NSString *)name {
    _name = name;
    self.nameLabel.text = self.name;
    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"NightMode"] == YES) {
        self.nameLabel.textColor = [UIColor whiteColor];
    } else {
        self.nameLabel.textColor = [UIColor blackColor];
    }
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.nameLabel.frame = CGRectMake((self.width - self.width / 3 * 2) / 2, (self.height - self.width / 3 * 2 / 2) / 2, self.width / 3 * 2, self.width / 3 * 2 / 2);
    
}

@end
